package org.devops


def ScanByPlugin(sourceDir){
    withSonarQubeEnv(credentialsId: 'c8c2adcf-6b45-4bb8-af11-b685ff6d70f9') {
    sh  """
        sonar-scanner -Dsonar.host.url=http://sonar.idevops.site \
        -Dsonar.branch.name=${env.branchName} \
        -Dsonar.projectKey=${env.serviceName} \
        -Dsonar.projectName=${env.serviceName} \
        -Dsonar.projectVersion=${env.branchName} \
        -Dsonar.login=${SONAR_AUTH_TOKEN} \
        -Dsonar.ws.timeout=30 \
        -Dsonar.projectDescription=${env.serviceName} \
        -Dsonar.links.homepage=http://gitlab.idevops.site/devops8/devops8-microservices-backend \
        -Dsonar.links.ci=${JOB_URL} \
        -Dsonar.sources=${sourceDir}/src \
        -Dsonar.sourceEncoding=UTF-8 \
        -Dsonar.java.binaries=${sourceDir}/target/classes \
        -Dsonar.java.test.binaries=${sourceDir}/target/test-classes \
        -Dsonar.java.surefire.report=${sourceDir}/target/surefire-reports
        """
    }
}

def ScanByCmd(){
     sh  """
        sonar-scanner -Dsonar.host.url=http://sonar.idevops.site \
        -Dsonar.projectKey=${env.serviceName} \
        -Dsonar.projectName=${env.serviceName} \
        -Dsonar.projectVersion=${env.branchName} \
        -Dsonar.login=admin \
        -Dsonar.password=admin123 \
        -Dsonar.ws.timeout=30 \
        -Dsonar.projectDescription=${env.serviceName} \
        -Dsonar.links.homepage=http://gitlab.idevops.site/devops8/devops8-microservices-backend \
        -Dsonar.links.ci=${JOB_URL} \
        -Dsonar.sources=${env.serviceName}/src \
        -Dsonar.sourceEncoding=UTF-8 \
        -Dsonar.java.binaries=${env.serviceName}/target/classes \
        -Dsonar.java.test.binaries=${env.serviceName}/target/test-classes \
        -Dsonar.java.surefire.report=${env.serviceName}/target/surefire-reports
        """
}